09. Quiz: Subquery Mania

Code

If you need a code on the https://github.com/udacity.

More Subqueries Quizzes

Above is the ERD for the database again - it might come in handy as you tackle the quizzes below. You should write your solution as a subquery or subqueries, not by finding one solution and copying the output. The importance of this is that it allows your query to be dynamic in answering the question - even if the data changes, you still arrive at the right answer.

  1. Provide the name of the sales_rep in each region with the largest amount of total_amt_usd sales.

  2. For the region with the largest (sum) of sales total_amt_usd, how many total (count) orders were placed?

  3. How many accounts had more total purchases than the account name which has bought the most standard_qty paper throughout their lifetime as a customer?

  4. For the customer that spent the most (in total over their lifetime as a customer) total_amt_usd, how many web_events did they have for each channel?

  5. What is the lifetime average amount spent in terms of total_amt_usd for the top 10 total spending accounts?

  6. What is the lifetime average amount spent in terms of total_amt_usd, including only the companies that spent more per order, on average, than the average of all orders.